<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" >
    <title>Title</title>
</head>
<body>

<h1>核酸检测系统</h1>
<form method="post" action="/medicalAssay/index">
    <select name="hospitalId" id="sel">
        <option value="">-请选择机构-</option>
    </select>
    <button type="submit">查询</button>
</form>
<a href="/medicalAssay/toAdd">添加</a>
<table border="1px">
    <tr>
        <td>被检测人</td>
        <td>被检测人手机号</td>
        <td>被检测人身份证</td>
        <td>检测机构</td>
        <td>检测日期</td>
        <td>检测结果</td>
        <td>操作</td>
    </tr>
    <tr th:each="i:${list}">
        <td th:text="${i.assayUser}"></td>
        <td th:text="${i.phone}"></td>
        <td th:text="${i.cardNum}"></td>
        <td th:text="${i.hospitalName}"></td>
        <td th:text="${i.assayTime}"></td>
        <td th:text="${i.assayResult==1}?'确诊':'检测中'"></td>
        <td>
            <a th:href="@{/medicalAssay/upd(id=${i.id})}">确诊</a>
        </td>
    </tr>
</table>


<script src="/webjars/jquery/3.4.1/jquery.js"></script>

<script>
    // window.location.href="/medicalAssay/index"
    $(function () {
        //请求后台拿到数据
        $.ajax({
            url:"/hospital",
            method:"get",
            dataType:"json",
            success:function (data) {
                console.log(data);
                var option = "<option value=\"\">-请选择机构-</option>";
                for (let i = 0; i < data.length; i++) {
                    option += "<option value=\""+data[i].id+"\">"+data[i].name+"</option>"
                }
                $("#sel").html(option);
            }
        })
    })
</script>


</body>
</html>